/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.japo.java.swing.samples;

import org.jdesktop.beansbinding.Converter;

/**
 *
 * @author José A. Pacheco Ondoño
 */
public class IntStringConverter extends Converter<String, Integer> {

    @Override
    public String convertReverse(Integer arg) {
        return String.valueOf(arg);
    }

    @Override
    public Integer convertForward(String arg) {
        int value;
        try {
            value = (arg == null) ? 0 : Integer.parseInt(arg);
        } catch (NumberFormatException ex) {
            value = 0;
        }
        return value;
    }
}
